package com.akrc.blog;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Data
@AllArgsConstructor
public class Greet {
	String message;
}

@RestController
class GreetController {
	String template = "Hello,%s!";

	@GetMapping("/greet")
	Greet greet(@RequestParam(value = "name", defaultValue = "World") String name) {
		return new Greet(String.format(template, Format(name)));
	}

	public static String Format(String name) {
		return name.substring(0, 1).toUpperCase() + name.substring(1);
	}
}